package com.suray.wcs.service.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.suray.basic.wcs.utils.IBaseEnum;

import java.io.Serializable;

public enum PrecessStatus implements IBaseEnum<Serializable> {
    CONDUCT(1, "进行中"),
    COMPLETE(100, "完成"),
    EXCEPTION(-1, "异常");

    @EnumValue
    private int precessStatus;
    @JsonValue
    private String description;

    PrecessStatus(int precessStatus, String description) {
        this.precessStatus = precessStatus;
        this.description = description;
    }

    @Override
    public String toString() {
        return description;
    }

    public static PrecessStatus parsePrecess(int precessStatus) {
        PrecessStatus[] precessStatuses = PrecessStatus.values();
        for (PrecessStatus type : precessStatuses) {
            if (type.precessStatus == precessStatus) {
                return type;
            }
        }
        throw new IllegalArgumentException("进度参数错误:" + precessStatus);
    }

    public static PrecessStatus getByPrecess(int precessStatus) {
        PrecessStatus[] precessStatuses = PrecessStatus.values();
        for (PrecessStatus type : precessStatuses) {
            if (type.precessStatus == precessStatus) {
                return type;
            }
        }
        return null;
    }

    public static PrecessStatus parsePrecess(String description) {
        PrecessStatus[] taskTypes = PrecessStatus.values();
        for (PrecessStatus type : taskTypes) {
            if (type.description.equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("进度描述错误:" + description);
    }

    public int getTypeNum() {

        return precessStatus;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public Integer getValue() {
        return precessStatus;
    }

    @Override
    public Integer getVal() {
        // TODO Auto-generated method stub
        return null;
    }


}
